package com.example.kuake.entity;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import lombok.Data;

import java.util.Date;

/**
 * 夸克网盘文件导出实体类
 */
@Data
public class QuarkFileExport {
    
    @ExcelProperty(value = "文件ID", index = 0)
    private String fid;
    
    @ExcelProperty(value = "文件名", index = 1)
    private String fileName;
    
    @ExcelProperty(value = "文件类型", index = 2)
    private String fileType;
    
    @ExcelProperty(value = "文件大小", index = 3)
    private Long size;
    
    @ExcelProperty(value = "父目录ID", index = 4)
    private String pdirFid;
    
    @ExcelProperty(value = "创建时间", index = 5)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date createdAt;
    
    @ExcelProperty(value = "修改时间", index = 6)
    @DateTimeFormat("yyyy-MM-dd HH:mm:ss")
    private Date updatedAt;
    
    @ExcelProperty(value = "文件来源", index = 7)
    private String source;
    
    @ExcelProperty(value = "是否文件夹", index = 8)
    private String isDirectory;
    
    @ExcelProperty(value = "包含项目数", index = 9)
    private Integer includeItems;
    
    @ExcelProperty(value = "格式类型", index = 10)
    private String formatType;
    
    @ExcelProperty(value = "下载链接", index = 11)
    private String downloadUrl;
    
    // 构造函数
    public QuarkFileExport() {}
    
    public QuarkFileExport(QuarkFile file) {
        this.fid = file.getFid();
        this.fileName = file.getFileName();
        this.fileType = file.getDir() ? "文件夹" : "文件";
        this.size = file.getSize();
        this.pdirFid = file.getPdirFid();
        this.createdAt = new Date(file.getCreatedAt() * 1000);
        this.updatedAt = new Date(file.getUpdatedAt() * 1000);
        this.source = file.getSource();
        this.isDirectory = file.getDir() ? "是" : "否";
        this.includeItems = file.getIncludeItems();
        this.formatType = file.getFormatType();
        this.downloadUrl = file.getDownloadUrl();
    }
}
